package org.openmore.consumer.service.feign;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.openmore.common.exception.OpenmoreException;
import org.openmore.consumer.dto.api.PlatformConfigDto;
import org.openmore.consumer.dto.common.BaseResponse;
import org.openmore.consumer.dto.common.PlatformConfig;
import org.openmore.consumer.entity.enums.PlatformType;
import org.openmore.consumer.service.feignImpl.DictionaryServiceImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE;

@Service
@FeignClient(value = "openmore-third-platform", fallbackFactory = DictionaryServiceImpl.class)
public interface PlatformConfigService {

    @ApiResponses(value = {@ApiResponse(code = 4000, message = "请求失败：原因", response = String.class)})
    @RequestMapping(method = RequestMethod.GET, value = "/api/platformconfig/select", produces = "text/plain;charset=utf-8")
    public BaseResponse selectAll(@RequestParam(required = false) @ApiParam(name = "应用ID") String tenantId,
                                  @RequestParam(required = false) @ApiParam(name = "平台类型") PlatformType platformType,
                                  @RequestParam(required = false) @ApiParam(name = "三方平台账户appid")String appid,
                                  @RequestParam(required = false) @ApiParam(name = "微信商户平台mchKey")String mchKey,
                                  @RequestParam(required = false, defaultValue = "1") @ApiParam(name = "页码")Integer pageNum,
                                  @RequestParam(required = false,  defaultValue = "10") @ApiParam(name = "每页条数") Integer pageSize);

    /**
     * 查询配置的平台信息数量
     */
    @ApiResponses(value = {@ApiResponse(code = 4000, message = "请求失败：原因", response = String.class)})
    @RequestMapping(method = RequestMethod.GET, value = "/api/platformconfig/count", produces = "text/plain;charset=utf-8")
    public BaseResponse selectCount(@RequestParam(required = false) @ApiParam(name = "应用ID") String tenantId,
                                    @RequestParam(required = false) @ApiParam(name = "平台类型")PlatformType platformType,
                                    @RequestParam(required = false) @ApiParam(name = "三方平台账户appid")String appid,
                                    @RequestParam(required = false) @ApiParam(name = "微信商户平台mchKey")String mchKey);
    /**
     * 保存平台配置信息
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/platformconfig", consumes = {APPLICATION_JSON_UTF8_VALUE})
    public BaseResponse insert(@RequestBody @ApiParam("平台配置信息") PlatformConfigDto platformConfig);
    /**
     * 更新平台配置信息
     */
    @RequestMapping(method = RequestMethod.PUT, value = "/api/platformconfig", consumes = {APPLICATION_JSON_UTF8_VALUE})
    public BaseResponse update(@RequestBody @ApiParam("平台配置信息")PlatformConfigDto platformConfig);
    /**
     * 删除平台配置信息
     */
    @RequestMapping(method = RequestMethod.DELETE, value = "/api/platformconfig/{id}")
    public BaseResponse deleteById(@PathVariable @ApiParam("配置项ID")String id);

    /**
     * 查询单条平台配置信息
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/platformconfig/{id}")
    public BaseResponse queryById(@PathVariable @ApiParam("配置项ID")String id);
}
